//
//  OpenGLFrameView.h
//  IntellDev_new
//
//  Created by os on 2021/3/10.
//

#import <UIKit/UIKit.h>

#include "H264DecoderDefine.h"

NS_ASSUME_NONNULL_BEGIN

@protocol OpenGLESViewPTZDelegate <NSObject>

@optional

- (void)cameraPTZ_Stop;
- (void)cameraPTZ_Left;
- (void)cameraPTZ_Right;
- (void)cameraPTZ_Up;
- (void)cameraPTZ_Down;
- (void)singleTouchOnOpenGLESView;

@end

@interface OpenGLGLRender_YUV : NSObject
{
    GLint   _uniformSamplers[3];
    GLuint  _textures[3];
}

- (BOOL)isValid;
- (NSString *)fragmentShader;
- (void)resolveUniforms:(GLuint)program;
- (void)setFrame:(H264YUV_Frame *)frame;
- (BOOL)prepareRender;

@end

@interface OpenGLFrameView : UIView
{
    
    EAGLContext                 *_context;
    GLuint                      _frameBuffer;
    GLuint                      _renderBuffer;
    GLuint                      _program;
    GLint                       _backingWidth;
    GLint                       _backingHeight;
    GLint                       _uniformMatrix;
    GLfloat                     _vertices[8];
    CGPoint                     begainPoint;
    
    OpenGLGLRender_YUV          *_render;
    
}

@property (nonatomic, weak) id<OpenGLESViewPTZDelegate> openGLESViewPTZDelegate;

- (void)render:(H264YUV_Frame *)frame;

@end

NS_ASSUME_NONNULL_END
